import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import './assets/global.css'
// 导入进度条插件
import NProgress from 'nprogress'
// 导入进度条样式
import 'nprogress/nprogress.css'
Vue.config.productionTip = false
Vue.use(VueQuillEditor)
//  挂载axios
Vue.prototype.axios = axios
Vue.component('tree-grid', ZkTable)
axios.defaults.baseURL = 'http://115.159.87.220:8888/api/private/v1/'
//  将请求进行拦截
axios.interceptors.request.use(config => {
  //  为所有请求携带token
  config.headers.Authorization = sessionStorage.getItem('token')
  //  发起请求时开启进度条
  NProgress.start()
  return config
})
//  每个请求完成响应数据 就隐藏
axios.interceptors.response.use(res => {
  NProgress.done()
  return res
})

//  定义时间过滤器 第一个形参永远是左边的数据
//  padStart(a,b) a是当在不满几位 进行补零 满足不会补零
Vue.filter('formatTime', (time) => {
  //  将秒转为毫秒进行年月日的转换
  const date = new Date(time * 1000)
  const y = date.getFullYear()
  const m = (date.getMonth() + 1).toString().padStart(2, 0)
  const d = date.getDate().toString().padStart(2, 0)
  return y + '-' + m + '-' + d
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
